#ifndef CAPTUREFILEVIEWER_H
#define CAPTUREFILEVIEWER_H

#include <QtGui/QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QPushButton>
#include <QSlider>
#include <QLabel>
#include <QTableWidget>
#include <QGroupBox>
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
#include "graphicsimageitem.h"

class CaptureFileViewer : public QWidget
{
    Q_OBJECT

public:
    CaptureFileViewer(QWidget *parent = 0);
    ~CaptureFileViewer();

    //const int CAMS = 24;

signals:
    void initTimeStamp(PFCMU::timestamp_t value);
    void timeStampChanged(PFCMU::timestamp_t value);
    void camChanged(int value);

    void testSignal(int value);

public slots:
    void onAddFiles();
    void onRemoveFile();
    void onRefreshView();
    void onSaveImg();
    void onAutoSaveImg();
    void onLoadBatchFiles();
    void onFrameChanged(int);
    void onCamsChanged(int);
    void setupViewMatrix(int size);
    void onSwitchToSingle(QString *file);
    void onSwitchToAll();

    void onPlay();
    void onOneFrameFinished();

    void onTestButton();
    void testSlot(int value);
    void onGoFrame();

private:
    void initScene();
    void initWindow();
    void resetFrameSlider(PFCMU::timestamp_t minValue, PFCMU::timestamp_t maxValue);
    void setTimeStampInc();

    QHBoxLayout *mainHLayout;
    QVBoxLayout *viewVLayout;
    QHBoxLayout *viewHLayout;
    QHBoxLayout *playHLayout;
    QHBoxLayout *camsSpliterHLayout;
    QHBoxLayout *framesSpliterHLayout;
    QHBoxLayout *batchLoadHLayout;
    QHBoxLayout *saveImgHLayout;
    QVBoxLayout *listVLayout;

    QGraphicsScene *captureScene;
    QGraphicsView *captureView;

    QPushButton *buttonViewAll;
    QLabel *labelSingleView;
    QPushButton *buttonPlay;
    QPushButton *buttonPause;
    QSlider *sliderZoom;
    QSlider *sliderCams;
    QSlider *sliderFrames;
    QLabel *labelCams;
    QLabel *labelFrames;
    QLabel *labelCurrentCam;
    QLabel *labelMinTimeStamp;
    QLabel *labelMaxTimeStamp;
//    QLabel *labelCurrentTimeStamp;
    QLineEdit *txtCurrentFrame;
    QPushButton *btnGoFrame;

    QLineEdit *txtBatchFileName;
    QPushButton *buttonLoadBatchFiles;
    QGroupBox *gbxFps;
    QHBoxLayout *fpsHLayout;
    QRadioButton *rdo25Fps;
    QRadioButton *rdo100Fps;
    QTableWidget *fileList;
    QPushButton *buttonAddFile;
    QPushButton *buttonRemoveFile;
    QPushButton *buttonRefresh;
    QPushButton *buttonSaveImg;
    QLineEdit *txtImgBaseName;
    QLabel *labelSaveFrames;
    QLineEdit *txtImgSaveCount;
    QPushButton *buttonAutoSaveImg;
    QCheckBox *chbCreateFolder;

    QPushButton *buttonTest;

    PFCMU::timestamp_t m_MinFileGroupTimeStamp;
    PFCMU::timestamp_t m_MaxFileGroupTimeStamp;
    int TIMESTAMPINC;
};

#endif // CaptureFileViewer_H
